<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>for循环</title>
</head>
<body>
	<script type="text/javascript">
		// 循环 来做1+2+3....+10000
		// 1+2+3+....+10000
		/*
		for(初始化条件;结束条件;递增条件){
			//run this code
		}
		*/
		var i;
		var sum = 0;
		for(i = 1; i <= 10000;i++){
			sum  = sum + i;
			// sum = 1 ,i = 2
			// sum = 3, i = 3
			// sum = 6, i = 4
		}
		console.log(sum);
		var shopping = ['香蕉','苹果','牛奶','红牛'];

		var j;
		for(j = 0; j < shopping.length; j ++){
		// console.log(shopping[j]);
			var htmlStr = '<h1>'+shopping[j]+'</h1>';
			console.log(htmlStr);
			document.write(htmlStr);
		}
</script>

</body>
</html>